package com.example.myzhugezhaofang.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.mvplibrary.adapter.BaseAdapter;
import com.example.mvplibrary.adapter.BaseViewHolder;
import com.example.myzhugezhaofang.R;
import com.example.myzhugezhaofang.bean.NavigationBean;

import java.util.List;

/**
 * 作者：朱勇闯
 * data : 2021/4/11  15:00
 * 作用： xxxx
 */
public class NavigationAdapter extends BaseAdapter<NavigationBean.ListBean> {
    public ItemListener itemListener;

    public void setItemListener(ItemListener itemListener) {
        this.itemListener = itemListener;
    }

    public NavigationAdapter(List<NavigationBean.ListBean> datas, Context context, int layoutId) {
        super(datas, context, layoutId);
    }

    @Override
    protected void bindData(BaseViewHolder holder, NavigationBean.ListBean listBean, int position) {
        ImageView iv_house_rv = holder.getView(R.id.iv_navigation_item);
        TextView tv_house_rv = holder.getView(R.id.tv_navigation_item);
        tv_house_rv.setText(listBean.getTitle());

        Glide.with(context).load(listBean.getIcon()).into(iv_house_rv);
//        itemListener.onItemClickListener(position);
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                itemListener.onItemClickListener(position);
            }
        });
    }

    public interface ItemListener {
        void onItemClickListener(int pos);
    }
}
